#include <iostream>
#include <ostream>
#include <stack>
//
// Created by lingzhitech on 25-9-16.
//
int main() {
    std::stack<int> intStack; // empty stack
    // fill up the stack
    for (size_t ix = 0; ix != 10; ++ix)
        intStack.push(ix); // intStackholds 0 ... 9 inclusive
    while (!intStack.empty()) { // while there are still values in intStack
        int value = intStack.top();
        // code that uses value
        std::cout << value << std::endl;
        intStack.pop(); // pop the top element, and repeat
    }
}